//
//  MainController.m
//  DIGICCY2
//
//  Created by mac on 2019/10/18.
//  Copyright © 2019 mac. All rights reserved.
//

#import "MainController.h"
#import <WebKit/WebKit.h>
#import "AppDelegate.h"

@interface MainController () <WKUIDelegate,WKNavigationDelegate>

@property (nonatomic, strong) WKWebView *webView;

@end

@implementation MainController

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //创建网页配置对象
    WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
    config.userContentController = [WKUserContentController new];
    //初始化
    _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, isPhoneX?44.0:20.0, kScreenW, isPhoneX?(kScreenH-44.0-34.0):(kScreenH-20.0)) configuration:config];
     // UI代理
//     _webView.UIDelegate = self;
//     // 导航代理
//     _webView.navigationDelegate = self;
     // 是否允许手势左滑返回上一级
   _webView.allowsBackForwardNavigationGestures = YES;
    
    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:delegate.baseUrl] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20];
    [_webView loadRequest:request];
    [self.view addSubview:_webView];
}


@end
